package com.skivingcloud.admin.sys.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.Table;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 *  实体类。
 *
 * @author skivingcloud
 * @since 2023-08-28
 */
@Table(value = "sys_org")
public class SysOrg implements Serializable {

    /**
     * 主键
     */
    @Id
    private String id;

    /**
     * 版本
     */
    private Integer version;

    /**
     * 自定义编号
     */
    @NotBlank(message = "机构编号不能为空")
    @Size(max = 255, message = "机构编号长度不能超过255")
    @Schema(title = "机构编号")
    private String orgCode;

    /**
     * 机构名称
     */
    @NotBlank(message = "机构名称不能为空")
    @Size(max = 1000, message = "机构名称长度不能超过1000")
    @Schema(title = "机构名称")
    private String orgName;

    /**
     * 简称
     */
    @Size(max = 255, message = "机构简称长度不能超过255")
    @Schema(title = "机构简称")
    private String shortName;

    /**
     * 租户
     */
    @NotBlank(message = "租户不能为空")
    @Size(max = 32, message = "租户ID长度不能超过32")
    @Schema(title = "租户ID")
    private String tenantId;

    /**
     * 级别
     */
    @Min(value = 0, message = "级别不能小于0")
    @Max(value = 99999, message = "级别不能大于99999")
    @Schema(title = "机构级别")
    private Integer orgLevel;

    /**
     * 上级id，顶级时该值为0
     */
    @NotBlank(message = "上级ID不能为空")
    @Size(max = 32, message = "上级ID长度不能超过32")
    @Schema(title = "上级ID")
    private String parentId;

    /**
     * 机构状态:
     */
    @Schema(title = "机构状态，字典100101")
    private String orgStatus;

    /**
     * 是否有叶子节点（0-叶子 1-父节点）
     */
    @Schema(title = "是否是叶子节点，0-否，1-是")
    private String isParent;

    /**
     * 机构分类：1-虚拟机构、2-实体机构
     */
    @Schema(title = "机构分类：1-虚拟机构、2-实体机构")
    private String orgType;

    /**
     * 扩展级别，例如：1-公司、2-部门、9-其他
     */
    @Schema(title = "扩展级别，例如：1-公司、2-部门、9-其他")
    private String orgRank;

    /**
     * 排序
     */
    @Min(value = 0, message = "排序不能小于0")
    @Max(value = 99999, message = "排序不能大于99999")
    @Schema(title = "排序")
    private Integer orderNum;

    /**
     * 创建人
     */
    @Schema(title = "创建人")
    private String creater;

    /**
     * 创建时间
     */
    @Schema(title = "创建时间")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;

    /**
     * 最后修改人
     */
    @Schema(title = "最后修改人")
    private String modUser;

    /**
     * 修改时间
     */
    @Schema(title = "修改时间")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime modTime;
    
    @Column(ignore = true)
    private List<SysOrg> children;
    
    @Column(ignore = true)
    private boolean disabled = false;
    
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public String getOrgCode() {
        return orgCode;
    }

    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }

    public String getOrgName() {
        return orgName;
    }

    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }

    public String getShortName() {
        return shortName;
    }

    public void setShortName(String shortName) {
        this.shortName = shortName;
    }

    public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    public Integer getOrgLevel() {
        return orgLevel;
    }

    public void setOrgLevel(Integer orgLevel) {
        this.orgLevel = orgLevel;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public String getOrgStatus() {
        return orgStatus;
    }

    public void setOrgStatus(String orgStatus) {
        this.orgStatus = orgStatus;
    }

    public String getIsParent() {
        return isParent;
    }

    public void setIsParent(String isParent) {
        this.isParent = isParent;
    }

    public String getOrgType() {
        return orgType;
    }

    public void setOrgType(String orgType) {
        this.orgType = orgType;
    }

    public String getOrgRank() {
        return orgRank;
    }

    public void setOrgRank(String orgRank) {
        this.orgRank = orgRank;
    }

    public Integer getOrderNum() {
        return orderNum;
    }

    public void setOrderNum(Integer orderNum) {
        this.orderNum = orderNum;
    }

    public String getCreater() {
        return creater;
    }

    public void setCreater(String creater) {
        this.creater = creater;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public String getModUser() {
        return modUser;
    }

    public void setModUser(String modUser) {
        this.modUser = modUser;
    }

    public LocalDateTime getModTime() {
        return modTime;
    }

    public void setModTime(LocalDateTime modTime) {
        this.modTime = modTime;
    }
    
    public List<SysOrg> getChildren(){
        return children;
    }
    
    public void setChildren(List<SysOrg> children){
        this.children = children;
    }
    
    public boolean isDisabled(){
        return disabled;
    }
    
    public void setDisabled(boolean disabled){
        this.disabled = disabled;
    }
}
